/**
 * 实验室管理数据model
 */
import {getLabPageManageList,saveLab,deleteLab} from 'api/labManageApi';

const labManage = {
    state: {
        labManagePageData:[],
        page: {
            currentPage: 1,
            pageSize: 5,
            total: 0
        },
        queryPara:{
            name: '',
        }
    },
    mutations: {
        loadLabManageMut(state, obj){
            if (obj.rows !== '') {
                state.labManagePageData = obj.rows;
                state.page.currentPage = obj.currentPage;
                state.page.pageSize = obj.pageSize;
                state.page.total = obj.total;
            }
        },
        setLabManageQueryPrams(state, obj){
            state.queryPara = obj;
        }

    },
    actions: {
        /*获取实验室列表*/
        getLabManagePageListAct (context, para) {
            return getLabPageManageList(para).then(res => {
                context.commit("loadLabManageMut",res.data);
            });
        },
        /*新增/编辑实验室*/
        saveLabAct (context, para) {
            return saveLab(para).then(res=>{
                return res.data;
            });
        },
        /*删除实验室*/
        deleteLabAct (context, para) {
            return deleteLab(para).then(res=>{
                return res.data;
            });
        },

    }
};

export default labManage;
